﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="tablecloth/tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="tablecloth/tablecloth.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php

include("inc/joomlaInt.php");
include("inc/inc_configuration.php");

if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{

	$gruppe=$_GET["gruppe"];

	$gId=$gruppe;

	
	$lq="SELECT leagueId FROM $tbl_lg WHERE id=$gId";
	$lqe=mysql_query($lq);
	$lqeo=mysql_fetch_object($lqe);
	
	$liga=$lqeo->leagueId;
	
	echo "<table><tr><th colspan='8'>";
	
	echo"	<FORM>
				<center><SELECT ONCHANGE='location = this.options[this.selectedIndex].value;'>";
				
				
	$gQ="SELECT id, groupName FROM $tbl_lg WHERE leagueId=$liga AND knockout=1";
	$gQe=mysql_query($gQ);
	
	while ($gr=mysql_fetch_object($gQe))
	{
		$id=$gr->id;
		$n=$gr->groupName;
		$t="";
		
		if ($id==$gId)
		{
			$t="selected";
		}
		echo"<OPTION $t VALUE='ko_spiele.php?gruppe=$id'>$n</option>";
	}
	
	echo "</select></center></th></tr>";

	
	
	$sQ="SELECT * FROM $tbl_matches WHERE stageId=$gId";
	$sQe=mysql_query($sQ);
	

	

	while ($row = mysql_fetch_object($sQe))
	{
		$mI=$row->id;
		$homeT=$row->homeT;
		$guestT=$row->guestT;
		$hG=$row->homeG;
		$gG=$row->guestG;
		$f=$row->free;
		
		if ($f==3)
		{
			$b="<a href='spielbericht.php?matchID=$mI&type=2'><img src='img/bericht.png' alt='Spielbericht'></a>";
		}
		else
		{
			$b="";
		}
		
		if ($hG=="")
		{
			$hG="-";
			$gG="-";
			$b="";
		}
		
		
		$tHq="SELECT name FROM $tbl_teams t WHERE t.id=$homeT";
		$tGq="SELECT name FROM $tbl_teams t WHERE t.id=$guestT";
		$tHqe = mysql_query($tHq);
		$tGqe = mysql_query($tGq);
		$tHn = mysql_fetch_object($tHqe)->name;
		$tGn = mysql_fetch_object($tGqe)->name;
		
		
		$uHSql="	SELECT u.username AS uHn, c.id AS hC, u.id AS uid FROM $tbl_combinations c, $tbl_users u
					WHERE
					(c.teamId=$homeT) AND
					(c.active=1) AND
					(c.userId=u.id)";
		$uGSql="	SELECT u.username AS uGn, c.id AS gC, u.id AS uid FROM $tbl_combinations c, $tbl_users u
					WHERE
					(c.teamId=$guestT) AND
					(c.active=1) AND
					(c.userId=u.id)";
		
		$uHq = mysql_query($uHSql);
		$uGq = mysql_query($uGSql);
		
		$uHqo=mysql_fetch_object($uHq);
		$uGqo=mysql_fetch_object($uGq);
		
		$uHn = $uHqo->uHn;
		$uGn = $uGqo->uGn;
		
		$uHi = $uHqo->uid;
		$uGi = $uGqo->uid;
		
		if ($uHn=="")
		{
			$uHn = "(-)";
		}
		else
		{
			$uHn="<a href='profil.php?id=$uHi'>$uHn</a>";
		}
		
		if ($uGn=="")
		{
			$uGn = "(-)";
		}
		else
		{
			$uGn="<a href='profil.php?id=$uGi'>$uGn</a>";
		}
		
		
		$ht=$row->homeT;
		$gt=$row->guestT;
		echo"<tr>	<td width='44%'><center><a href='spiele_team.php?team=$ht&liga=$liga'>$tHn</a><br>$uHn</td>
					<td><a href='team_kader.php?team=$ht'><img src='img/logos/",$ht,".png' width='35' height='35' alt=''></a></td>
					<td width='3%'><center>$hG</center></td>
					<td width='2%'><center>:</center></td>
					<td width='3%'><center>$gG</center></td>
					<td><a href='team_kader.php?team=$gt'><img src='img/logos/",$gt,".png' width='35' height='35' alt=''></a></td>
					<td width='44%'><center><a href='spiele_team.php?team=$gt&liga=$liga'>$tGn</a><br>$uGn</center></td>
					<td width='4%'><center>$b</center></td>
			</tr>";
	}

	echo "<tr><th colspan='8'></th></tr></table><br><br>";




echo "<br><br>
			<center><a href='lima.php' class='button zurueck'>Zurück</a></center>";

}
?>

</body>
</html>